package com.example.lab3.Controller;

import com.example.lab3.Entity.DataModel;
import com.example.lab3.Impl.getDataImpl;
import com.example.lab3.Service.DataModelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;


import javax.annotation.Resource;
import java.io.IOException;

@Controller
public class DataModelController {

    @Autowired
    private DataModelService service;
    @Autowired
    private getDataImpl get;

    @GetMapping ("show")
    public String getData(Model model) throws IOException {
        model.addAttribute("listData",service.getData());
        return "index";
    }

    @GetMapping ("search")
    public String getData2(String address, Model model) throws IOException {
        model.addAttribute("listData",get.searchDataModel(address));
        System.out.println(get.searchDataModel(address));
        return "index";
    }

}
